/**
 * Copyright (c) 快宝网络 kuaidihelp.com Co., Ltd. All Rights Reserved 禁止外泄以及用于其它的商业用途
 */

import type { StringObjType } from '@/components/_pages/AmountApply/index.d';
import request from '@/utils/request';
import { message } from 'antd';

export async function getAmountverifyList(params: StringObjType): Promise<any> {
  const { status, isShow, ...rest } = params;
  if (isShow !== undefined && !isShow) return;
  const payload = {
    ...rest,
    status: status === '10001' ? '' : status === undefined ? '0' : status,
  };
  return request('/LargeAmountApply/applyList', {
    method: 'POST',
    data: { ...payload },
  }).then(({ code, data, msg }) => {
    if (code == 0) {
      return {
        data: data.list,
      };
    }
    if (code != 0) {
      message.error(msg);
    }
    return {};
  });
}

export async function verifyAmount(params: StringObjType): Promise<any> {
  return request('/LargeAmountApply/review', {
    method: 'POST',
    data: { ...params },
  }).then(({ code, msg }) => {
    if (code == 0) {
      message.info('操作成功');
    }
    if (code != 0) {
      message.error(msg);
    }
    return { code };
  });
}

export async function getApplyRecord(params: StringObjType): Promise<any> {
  const { current: page, pageSize: size } = params;
  return request('/LargeAmountApply/applyRecord', {
    method: 'POST',
    data: { page, size },
  }).then(({ code, data, msg }) => {
    if (code == 0) {
      return {
        data: data.list,
        total: data.count,
      };
    }
    if (code != 0) {
      message.error(msg);
    }
    return {};
  });
}

export async function saveApplyCash(params: StringObjType): Promise<any> {
  return request('/LargeAmountApply/applyCash', {
    method: 'POST',
    data: { ...params },
  }).then(({ code, msg }) => {
    if (code == 0) {
      message.info('操作成功');
    }
    if (code != 0) {
      message.error(msg);
    }
    return { code };
  });
}
